package com.nandi.deviceinstall.net


import com.nandi.deviceinstall.bean.*
import com.nandi.deviceinstall.net.dto.BindAddDTO
import com.nandi.deviceinstall.net.dto.BindUpdateDTO
import com.nandi.deviceinstall.net.dto.DataDTO
import com.nandi.deviceinstall.net.dto.TapAddDTO

import io.reactivex.Flowable
import okhttp3.MultipartBody
import okhttp3.RequestBody
import okhttp3.ResponseBody
import org.intellij.lang.annotations.Flow
import retrofit2.http.*
import java.io.File


interface APIService {

    /**
     * 登陆
     *
     * @param username 账号
     * @param password 密码
     * @return
     */
    @GET("auth/oauth/token")
    fun login(@Header("Authorization") authorization: String,
              @Query("grant_type") grant_type: String,
              @Query("scope") scope: String,
              @Query("username") username: String,
              @Query("password") password: String): Flowable<LoginBean>


    @GET("monitorpoint/tabmonitorinfo/page")
    fun listTapRecord(@Header("Authorization") authorization: String,
                      @Query("current") current: Int,
                      @Query("size") size: Int,
                      @Query("monitorMethod") monitorMethod: Int,
                      @Query("areaCode") areaCode: String,
                      @Query("sort") sort: Int,
                      @Query("townCode") townCode: String,
                      @Query("disasterName") disasterName: String,
                      @Query("disNo") disNo: String,
                      @Query("monitorNo") monitorNo: String,
                      @Query("startTime") startTime: String,
                      @Query("endTime") endTime: String,
                      @Query("isAppAdd") isAppAdd: Int): Flowable<TapRecordBean>


    @GET("disaster/tabarea/district")
    fun listCity(@Header("Authorization") authorization: String,
                 @Query("district") district: String): Flowable<CityBean>

    @GET("device/tabarea/getArea/{id}")
    fun listTown(@Header("Authorization") authorization: String,
                 @Path("id") id: Int): Flowable<TownBean>



    @POST("monitorpoint/tabmonitorinfo")
    fun addTap(@Header("Authorization") authorization: String, @Body tapAddDTO: TapAddDTO): Flowable<TapAddResultBean>

    @PUT("monitorpoint/tabmonitorinfo")
    fun updateTap(@Header("Authorization") authorization: String, @Body tapAddDTO: TapAddDTO): Flowable<TapAddResultBean>

    @Multipart
    @POST("monitorpoint/monitorpoint/upload/pic")
    fun uploadPic(@Header("Authorization") authorization: String,
                  @Part file: MultipartBody.Part,
                  @Part("type") type: RequestBody): Flowable<UploadPicBean>

    @Multipart
    @POST("device/devdeviceinfo/image")
    fun uploadDevPic(@Header("Authorization") authorization: String,
                     @Part file: MultipartBody.Part): Flowable<UploadPicBean>

    //下载图片
    @Streaming
    @GET("monitorpoint/tabmonitorinfo/toStream")
    fun downPic(@Header("Authorization") authorization: String,
                @Query("path") path: String,
                @Query("type") type: Int): Flowable<ResponseBody>

    @DELETE("monitorpoint/monitorpoint/remove/pic/file")
    fun removePicFile(@Header("Authorization") authorization: String,
                      @Query("sourcePath") sourcePath: String,
                      @Query("type") type: Int): Flowable<RemovePicBean>

    @DELETE("device/devdeviceinfo/remove/image")
    fun removeDevPicFile(@Header("Authorization") authorization: String,
                         @Query("path") sourcePath: String): Flowable<DevPicRemoveBean>

    @GET("monitorpoint/tabmonitorinfo/monitor/{id}")
    fun getTapRecordInfo(@Header("Authorization") authorization: String,
                         @Path("id") id: Int): Flowable<TapRecordInfoBean>

    @DELETE("monitorpoint/tabmonitorinfo/app/{id}")
    fun deleteTapRecord(@Header("Authorization") authorization: String,
                        @Path("id") id: Int): Flowable<DeleteBean>

    @GET("device/devdeviceinfo/app/{id}")
    fun getBindRecordInfo(@Header("Authorization") authorization: String,
                          @Path("id") id: Int): Flowable<BindRecordInfoBean>

    @DELETE("device/devdeviceinfo/app/{id}")
    fun deleteBindRecord(@Header("Authorization") authorization: String,
                         @Path("id") id: Int): Flowable<BindDeleteBean>

    @GET("disaster/tblhazardbasicinfo/disName")
    fun getDisNum(@Header("Authorization") authorization: String,
                  @Query("disName") disName: String,
                  @Query("areaCode") areaCode: String): Flowable<DisNumBean>


    @GET("monitorpoint/tabmonitorinfo/monitorSettingInfo")
    fun listMonitorNum(@Header("Authorization") authorization: String,
                       @Query("unifiedCode") unifiedCode: String): Flowable<ListMonitorNumBean>

    @GET("device/devfactory/all")
    fun listDevFactory(@Header("Authorization") authorization: String,
                       @Query("factory") factory: String): Flowable<DeviceFacBean>

    @GET("disaster/tblhazardbasicinfo/page?current=1&size=1000")
    fun listDisName(@Header("Authorization") authorization: String,
                    @Query("disasterName") disasterName: String,
                    @Query("town") town: String): Flowable<DisNameBean>
    
    @GET("disaster/tblhazardbasicinfo/app")
    fun listDisaster(@Header("Authorization") authorization: String,
                     @Query("town") areaCode: String): Flowable<DisasterBean>

    @POST("device/devdeviceinfo/app")
    fun addBind(@Header("Authorization") authorization: String, @Body bindAddDTO: BindAddDTO): Flowable<BaseObjectBean<BindAddBean>>

    @PUT("device/devdeviceinfo/app")
    fun updateBind(@Header("Authorization") authorization: String, @Body bindAddDTO: BindUpdateDTO): Flowable<BaseObjectBean<BindAddBean>>

    @GET("device/devicedata/app/data")
    fun getData(@Header("Authorization") authorization: String, @Query("devId") devId: String): Flowable<ListDataBean>

    @GET("device/devdeviceinfo/app/records")
    fun listBindRecord(@Header("Authorization") authorization: String,
                       @Query("current") current: Int,
                       @Query("size") size: Int,
                       @Query("areaCode") areaCode: String,
                       @Query("sort") sort: Int,
                       @Query("townCode") townCode: String,
                       @Query("disasterName") disasterName: String,
                       @Query("disNo") disNo: String,
                       @Query("monitorNo") monitorNo: String,
                       @Query("startTime") startTime: String,
                       @Query("endTime") endTime: String,
                       @Query("isAppAdd") isAppAdd: Int,
                       @Query("devType") devType: Int,
                       @Query("devName") devName: String,
                       @Query("devFactory") devFactory: String): Flowable<BindRecordBean>

}
